Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 11, 2026

  • Add BLE_logStreamVname constant to constants.dart
  • Add custom characteristic definition for BLE logging (0x30) to customCharacteristicFramework
  • Create ble_log_screen.dart with log viewer UI
  • Update main_device_screen.dart to add navigation to BLE Log screen
  • Automatically enable log streaming on screen entry
  • Automatically disable log streaming on screen exit
  • Display streamed logs with scrollable text view
  • Handle connection/disconnection states appropriately
  • Add demo mode support with simulated log messages
  • Run flutter analyze - passed with no errors in new code
  • Create UI documentation and mockups
  • Add Save and Send functionality for logs
  • Create expandable Maintenance section grouping Update Firmware and View Logs

Implementation Summary

This PR adds a dedicated BLE Log Viewer screen that integrates with the SmartSpin2k firmware's new BLE log streaming capability (see doudar/SmartSpin2k#714).

Key Features

Automatic Log Streaming:

  • Automatically enables log streaming (writes "1" to characteristic 0x30) when entering the screen
  • Automatically disables log streaming (writes "0" to characteristic 0x30) when exiting the screen
  • No manual toggle required - streaming is managed by screen lifecycle

User Interface:

  • Expandable Maintenance Section on main device screen
    • Groups "Update Firmware" and "View Logs" options
    • Expands/collapses when tapped
    • Uses build icon for visual consistency
  • Status indicator showing "Log streaming is active"
  • "Save" button - Saves logs to device storage with timestamped filename
  • "Send" button - Shares logs via system share dialog (email, messaging, etc.)
  • "Clear" button to clear displayed logs
  • Scrollable log display with monospace font for easy reading
  • Auto-scroll to bottom when new messages arrive
  • Selectable text for easy copying
  • Connection status indicator

Demo Mode:

  • Generates simulated log messages every 2 seconds for testing without hardware
  • Allows UI development and testing without physical SmartSpin2k device

Technical Details

  • Uses BLE characteristic 0x30 (BLE_BLELogging) for log streaming control and message retrieval
  • Saves logs to application documents directory with timestamped filenames (e.g., ble_logs_2026-01-12T17-13-25.txt)
  • Uses share_plus package for sharing logs via system share sheet
  • Expandable card pattern for better organization of maintenance-related features
  • Follows existing app patterns and conventions
  • Proper resource cleanup on screen disposal
  • Handles connection/disconnection states appropriately
  • Compatible with SmartSpin2k firmware that includes BLE log streaming support

The implementation is minimal and focused, reusing existing functions and patterns to keep the change set small.

Original prompt

Add a dedicated screen in the SmartSpin2k Config App to view BLE logs that are now available from the SmartSpin2k firmware (see doudar/SmartSpin2k#714). Implement a BLE log viewer that reuses existing functions and patterns in the app to keep the change set small. The screen should allow users to see streamed logs, with a runtime toggle to enable/disable BLE log streaming (matching the firmware’s new capability) and the ability to read existing log output. Ensure UI navigation exposes this new screen and that error/loading states are handled consistently with the app’s existing conventions. Provide any necessary tests or updates to documentation if applicable.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@doudar
Copy link
Owner

doudar commented Jan 11, 2026

@copilot I think there was an internet outage and it's back now. YOu can try this again

@doudar
Copy link
Owner

doudar commented Jan 12, 2026

@copilot Lets try this again. There was an internet interruption which stopped your progress last time. Also, I notice in your summary, you have a toggle to enable/disable logs. Instead of using a button, that command should be automatically sent to enable upon entering the screen and automatically disabled when leaving the screen. doudar's avatar

@doudar
Copy link
Owner

doudar commented Jan 12, 2026

@copilot

Lets try this again. There was an internet interruption which stopped your progress last time. Also, I notice in your summary, you have a toggle to enable/disable logs. Instead of using a button, that command should be automatically sent to enable upon entering the screen and automatically disabled when leaving the screen. doudar's avatar

@doudar
Copy link
Owner

doudar commented Jan 12, 2026

@copilot Installing the linux dependencies to test build seems to be causing you issues. Please skip that step.

Copy link
Contributor Author

Copilot AI commented Jan 12, 2026

@copilot Installing the linux dependencies to test build seems to be causing you issues. Please skip that step.

Understood. I've completed the implementation without building. Here's what the BLE Log screen looks like:

Main Device Screen - Added new "BLE Logs" navigation card:

┌────────────────────────────────────────────────────┐
│  [📄]  BLE Logs                                 →  │
└────────────────────────────────────────────────────┘

BLE Log Screen with logs:

╔═══════════════════════════════════════════════════╗
║  BLE Logs                         [Device Info]   ║
╠═══════════════════════════════════════════════════╣
║  ┌───────────────────────────────────────────┐   ║
║  │  ℹ  Log streaming is active               │   ║
║  │                                            │   ║
║  │  [🔄 Read Current]  [🗑️ Clear]            │   ║
║  └───────────────────────────────────────────┘   ║
║  ┌───────────────────────────────────────────┐   ║
║  │  [2026-01-12T17:00:01] Device starting... │   ║
║  │  [2026-01-12T17:00:02] BLE initialized    │   ║
║  │  [2026-01-12T17:00:03] FTMS ready         │   ║
║  │  [2026-01-12T17:00:04] Device ready       │   ║
║  │                                         ▲  │   ║
║  │                                         ▼  │   ║
║  └───────────────────────────────────────────┘   ║
╚═══════════════════════════════════════════════════╝

Key features implemented:

  • ✅ Automatic enable (writes "1" to 0x30) on entry
  • ✅ Automatic disable (writes "0" to 0x30) on exit
  • ✅ Scrollable log display with monospace font
  • ✅ Demo mode with simulated logs
  • ✅ Read Current and Clear buttons
  • ✅ Connection status indicator

Commit: 6904f47

Copilot AI changed the title [WIP] Add BLE log viewer screen to SmartSpin2k Config App Add BLE log viewer screen to SmartSpin2k Config App Jan 12, 2026
@doudar
Copy link
Owner

doudar commented Jan 12, 2026

@copilot Instead of read current, lets add a save and send buttons.

Copy link
Contributor Author

Copilot AI commented Jan 12, 2026

@copilot Instead of read current, lets add a save and send buttons.

Updated the BLE Log screen with Save and Send buttons:

New Control Panel:

╔═══════════════════════════════════════════════════╗
║  ℹ  Log streaming is active                       ║
║                                                    ║
║  [💾 Save]  [📤 Send]  [🗑️ Clear]                 ║
╚═══════════════════════════════════════════════════╝

Functionality:

  • Save button: Saves logs to device storage with timestamped filename (e.g., ble_logs_2026-01-12T17-13-25.txt)
  • Send button: Opens system share dialog to send logs via email, messaging, etc.
  • Clear button: Clears displayed logs (unchanged)

All three buttons are disabled when no logs are present.

Commit: 2bea487

@doudar
Copy link
Owner

doudar commented Jan 12, 2026

@copilot This is looking good! Now, I think we should put "Update Firmware" and BLE Logs (lets rename that item "View Logs") into a combined option called "Maintenance" that expands showing the "Update Firmware and "View Logs" when clicked on the main device screen.

Copy link
Contributor Author

Copilot AI commented Jan 12, 2026

@copilot This is looking good! Now, I think we should put "Update Firmware" and BLE Logs (lets rename that item "View Logs") into a combined option called "Maintenance" that expands showing the "Updat...

Created an expandable Maintenance section on the main device screen:

Main Device Screen - Collapsed:

┌────────────────────────────────────────────────────┐
│  [🎮]  Virtual Shifter                          →  │
├────────────────────────────────────────────────────┤
│  [⚙️]  Settings                                    →  │
├────────────────────────────────────────────────────┤
│  [📊]  Power Table                                 →  │
├────────────────────────────────────────────────────┤
│  [🏃]  Workout                                     →  │
├────────────────────────────────────────────────────┤
│  [🔧]  Maintenance                                 ▼  │  ← NEW
└────────────────────────────────────────────────────┘

Main Device Screen - Expanded:

┌────────────────────────────────────────────────────┐
│  [🏃]  Workout                                     →  │
├────────────────────────────────────────────────────┤
│  [🔧]  Maintenance                                 ▲  │
│  ─────────────────────────────────────────────────  │
│  [📥]  Update Firmware                            →  │
│  ─────────────────────────────────────────────────  │
│  [📄]  View Logs                                  →  │
└────────────────────────────────────────────────────┘

Changes:

  • ✅ Created expandable "Maintenance" section with build icon
  • ✅ Moved "Update Firmware" into Maintenance section
  • ✅ Renamed "BLE Logs" to "View Logs" and moved into Maintenance section
  • ✅ Tap to expand/collapse with visual indicator (▼/▲)
  • ✅ Updated "View Logs" screen title

Commit: 6f276b4

Copilot AI changed the title Add BLE log viewer screen to SmartSpin2k Config App Add BLE log viewer screen with expandable Maintenance section to SmartSpin2k Config App Jan 12, 2026
@doudar doudar marked this pull request as ready for review January 13, 2026 03:22
@doudar doudar merged commit 655ec0f into develop Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants